/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package SPMModel.impl;

import SPMModel.Performer;
import SPMModel.Role;
import SPMModel.RoleDescriptor;
import SPMModel.SPMModelPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Role Descriptor</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link SPMModel.impl.RoleDescriptorImpl#getPerformer <em>Performer</em>}</li>
 *   <li>{@link SPMModel.impl.RoleDescriptorImpl#getIs <em>Is</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RoleDescriptorImpl extends EObjectImpl implements RoleDescriptor {
	/**
	 * The default value of the '{@link #getPerformer() <em>Performer</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPerformer()
	 * @generated
	 * @ordered
	 */
	protected static final Performer PERFORMER_EDEFAULT = Performer.PRIMARY;

	/**
	 * The cached value of the '{@link #getPerformer() <em>Performer</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPerformer()
	 * @generated
	 * @ordered
	 */
	protected Performer performer = PERFORMER_EDEFAULT;

	/**
	 * The cached value of the '{@link #getIs() <em>Is</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIs()
	 * @generated
	 * @ordered
	 */
	protected Role is;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RoleDescriptorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SPMModelPackage.Literals.ROLE_DESCRIPTOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Performer getPerformer() {
		return performer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPerformer(Performer newPerformer) {
		Performer oldPerformer = performer;
		performer = newPerformer == null ? PERFORMER_EDEFAULT : newPerformer;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.ROLE_DESCRIPTOR__PERFORMER, oldPerformer, performer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Role getIs() {
		if (is != null && is.eIsProxy()) {
			InternalEObject oldIs = (InternalEObject)is;
			is = (Role)eResolveProxy(oldIs);
			if (is != oldIs) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, SPMModelPackage.ROLE_DESCRIPTOR__IS, oldIs, is));
			}
		}
		return is;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Role basicGetIs() {
		return is;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIs(Role newIs) {
		Role oldIs = is;
		is = newIs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.ROLE_DESCRIPTOR__IS, oldIs, is));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SPMModelPackage.ROLE_DESCRIPTOR__PERFORMER:
				return getPerformer();
			case SPMModelPackage.ROLE_DESCRIPTOR__IS:
				if (resolve) return getIs();
				return basicGetIs();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SPMModelPackage.ROLE_DESCRIPTOR__PERFORMER:
				setPerformer((Performer)newValue);
				return;
			case SPMModelPackage.ROLE_DESCRIPTOR__IS:
				setIs((Role)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SPMModelPackage.ROLE_DESCRIPTOR__PERFORMER:
				setPerformer(PERFORMER_EDEFAULT);
				return;
			case SPMModelPackage.ROLE_DESCRIPTOR__IS:
				setIs((Role)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SPMModelPackage.ROLE_DESCRIPTOR__PERFORMER:
				return performer != PERFORMER_EDEFAULT;
			case SPMModelPackage.ROLE_DESCRIPTOR__IS:
				return is != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (performer: ");
		result.append(performer);
		result.append(')');
		return result.toString();
	}

} //RoleDescriptorImpl
